﻿' Copyright (C) 2011  Jan-Willem de Bruyn
'
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Imports System.IO
Imports System.Net
Imports System.Text

Public Class filedownload
    Inherits System.Web.UI.Page
    Dim mywebclient As New WebClient()
    Dim pagehtmlbytes() As Byte
    Dim outf8 As UTF8Encoding = New UTF8Encoding()

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        pagehtmlbytes = mywebclient.DownloadData(TextBox1.Text)

        Response.AddHeader("Content-disposition", "attachment; filename=" & TextBox1.Text)

        Response.Write(outf8.GetString(pagehtmlbytes).ToString)
        Response.End()

    End Sub
End Class